import { App } from "vue"
import dayjs from "dayjs"
import utc from "dayjs/plugin/utc"

dayjs.extend(utc)

// const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss"
const DATE_TIME_FORMAT = "YYYY-MM-DD"
const timePulgin = {
  mounted(el: HTMLElement, binds: any): void {
    // 将毫秒转成格式化的时间
    el.innerHTML = dayjs(0).millisecond(Number.parseInt(el.innerHTML)).format(DATE_TIME_FORMAT)
  }
}
export default {
  install(app: App) {
    app.directive("format-time", timePulgin)
  }
}
